package spring;

import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class HelloWorldTest {

    // @Autowired
    // @Qualifier(value = "helloWorldChineseImpl")

    @Resource
    @Qualifier(value = "helloWorldChineseImpl")
    private HelloWorld helloWorld;
 
/*    public void setHelloWorldEnglishImpl(HelloWorld helloWorld) {
        this.helloWorld = helloWorld;
    }*/
 
    public void doSay(){
        helloWorld.say();
    }
}
 
class Test{
    public static void main(String[] args) {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        HelloWorldTest test = (HelloWorldTest) context.getBean("helloWorldTest");
        test.doSay();
        //打印结果：Hello World
    }
}